package pasantias.Dominio;

public class BoardBuilder {
	
	private final BoardMutable board;
	
	public BoardBuilder(int x, int y){
		board = new BoardMutable(x, y);
	}
	
	public BoardBuilder addFigure(Rectangle rectangle){
		try {
			board.addFigure(rectangle);
			return this;
		}
		catch (RuntimeException runtimeException){
			throw runtimeException;
		}
	}
	
	public BoardBuilder addFigure(Circle circle){
		try{
			board.addFigure(circle);
			return this;
		}
		catch (RuntimeException runtimeException){
			throw runtimeException;
		}
	}
	
	public BoardBuilder addFigure(Dot dot){
		try{
			board.addFigure(dot);
			return this;
		}
		catch (RuntimeException runtimeException){
			throw runtimeException;
		}
	}
	
	public InmutableBoard build(){
		InmutableBoard boardInmutable = new InmutableBoard(board.getWidth(),board.getHeight(),board.getFigures());
		return boardInmutable;
	}

}
